'use strict'

class message {

    constructor() {
        this.param = '/'
    }

    //创建资源
    async post(c) {
        var openid = c.box.user.openid;
        //www.h5fd.xyz:2021/user/message
            try {
                var newName = JSON.parse(c.body.toString('utf-8')).newName;
                let sqltext1 = `UPDATE USERS `
                    + `SET user_nickname = '${newName}' `
                    + `WHERE openid = '${openid}'`;
                var r1 = await c.service.psql.query(sqltext1);
                return c.send('success');
            } catch (err) {
                c.status(400).send('error');
                console.log(err);
            }
    }
}

module.exports = message